<template>
  <div class="cs-page-container">
    <div class="cs-filter-container">
      <el-select
        v-model="listQuery.bundleId"
        clearable
        placeholder="包名"
      >
        <el-option label="花伴交友app安卓" value="com.vchat.flower" />
        <el-option label="花伴交友app苹果" value="com.vchat.flower.ios" />
        <el-option label="花伴约会app安卓" value="com.date.flower" />
        <el-option label="花伴约会app苹果" value="com.date.flower.ios" />
        <el-option label="成人约会圈app安卓" value="com.chengren.yhq" />
        <el-option label="他趣附近约会app安卓" value="com.funnychat.mask" />
      </el-select>
      <el-date-picker
        v-model="daterangeValue"
        :picker-options="daterangePickerOptions"
        type="daterange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="起始时间"
        end-placeholder="结束时间"
        value-format="yyyy-MM-dd"
        clearable
        @change="daterangeChangedTimestamp"
      />
      <el-button
        type="primary"
        icon="el-icon-search"
        :loading="listLoading"
        @click="handleFilter"
      >查询</el-button>
      <el-button
        type="info"
        size="small"
        icon="el-icon-refresh-right"
        @click="resetFilter"
      >重置</el-button>
    </div>
    <div class="cs-filter-result">
      <el-table
        v-loading="listLoading"
        :data="list"
        :height="'calc(100vh - 250px)'"
        border
        fit
        size="small"
        highlight-current-row
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
      >
        <el-table-column align="center" label="日期" prop="targetDate"> </el-table-column>
        <el-table-column align="center" label="参与用户数" prop="accountNum"> </el-table-column>
        <el-table-column align="center" label="当前红包奖池" prop="paketPool"> </el-table-column>
        <el-table-column align="center" label="当前机器人池" prop="robotPool"> </el-table-column>
        <el-table-column align="center" label="开奖次数" prop="totalOpen"> </el-table-column>
        <el-table-column align="center" label="开红包次数" prop="openPacket"> </el-table-column>
        <el-table-column align="center" label="领红包次数" prop="redPacketNum"> </el-table-column>
        <el-table-column align="center" label="领红包人数" prop="accountPacket"> </el-table-column>
        <el-table-column align="center" label="红包发放花粉数" prop="rebPrice">
          <template slot-scope="{ row }">
            <span>{{ row.rebPrice ? row.rebPrice : 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="抽水花粉数">
          <template slot-scope="{ row }">
            <span>{{ row.joinPrice * 0.04 }}</span>
          </template>
        </el-table-column>
      </el-table>
      <TablePagination
        :current-page="listQuery.page"
        :limit="listQuery.limit"
        :total="total"
        :loading="listLoading"
        @handleSizeChange="handleSizeChange"
        @handleCurrentChange="handleCurrentChangeOffset"
      />
    </div>
  </div>
</template>

<script>
import TablePagination from '@/components/TablePagination'
import { xhrGetTurnStatisticsList } from '@/api/analysis'
export default {
  name: 'Turntable',
  components: { TablePagination },
  data() {
    return {
      daterangeValue: '',
      list: [],
      total: 0,
      listQuery: {
        offset: 0,
        limit: 100,
        bundleId: null,
        startTime: null,
        endTime: null,
        gender: null
      }
    }
  },

  created() {
    this.doSearch()
  },

  methods: {
    doSearch() {
      xhrGetTurnStatisticsList(this.listQuery).then(resp => {
        console.log(resp)
        this.total = resp.data.count
        this.list = resp.data.list
        this.listLoading = false
      }).catch(resp => {
        console.log(resp)
        this.listLoading = false
      })
    },
    onGoDetail(id) {
      this.$router.push('/account/account-detail?id=' + id)
    }
  }
}
</script>

<style scoped>

</style>
